set(FIBOPATH  "fibo-crosstool_AN758_V1.0.10_V10_DualCore")
# 设置交叉编译工具链的基本路径
set(CCTOOLBASE "/opt/${FIBOPATH}/fibo-crosstool/gcc-cross-aarch64-8.2.0" CACHE PATH "Cross toolchain base directory")

# 定义工具链中的工具路径
set(CCTOOLS "${CCTOOLBASE}/toolchain/usr/bin:${CCTOOLBASE}/toolchain/usr/bin/aarch64-poky-linux" CACHE STRING "Paths to cross tools")
set(CROSS_COMPILE "aarch64-poky-linux-" CACHE STRING "Prefix for cross compilation tools")

# 设置编译器和相关工具
set(CMAKE_C_COMPILER   ${CROSS_COMPILE}gcc CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER ${CROSS_COMPILE}g++ CACHE FILEPATH "C++ compiler")
set(CMAKE_AR           ${CROSS_COMPILE}ar CACHE FILEPATH "Archiver")
set(CMAKE_AS           ${CROSS_COMPILE}as CACHE FILEPATH "Assembler")
set(CMAKE_LD           ${CROSS_COMPILE}ld CACHE FILEPATH "Linker")
set(CMAKE_NM           ${CROSS_COMPILE}nm CACHE FILEPATH "Symbol name list generator")
set(CMAKE_STRIP        ${CROSS_COMPILE}strip CACHE FILEPATH "Strip symbols from binary")
set(CMAKE_RANLIB       ${CROSS_COMPILE}ranlib CACHE FILEPATH "Index archive generator")

# 设置头文件和库文件路径
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "${CCTOOLBASE}/sysroot/usr/include" CACHE STRING "Implicit include directories")
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "${CCTOOLBASE}/sysroot/usr/include" CACHE STRING "Implicit include directories")

set(CCLIBS_X86 "${CCTOOLBASE}/toolchain/usr/lib" CACHE PATH "Library path for x86")
set(CCLIBS "${CCTOOLBASE}/sysroot/usr/lib64" CACHE PATH "Library path for target architecture")

# # 设置运行时的动态库路径
# set(LIB_RPATH "/umdp/lib:/oemapp/lib:/oemapp/xdja_idps/lib:/oemapp/lib/someip:/oemapp/lib/server:/oemapp/lib/client:/oemapp/exd_connector/lib:/oemapp/soa/soa_client/lib" CACHE STRING "Runtime library paths")

# 设置编译选项
set(CMAKE_C_FLAGS "-O2 -DMT2735 --sysroot=${CCTOOLBASE}/sysroot" CACHE STRING "C compiler flags")
set(CMAKE_CXX_FLAGS "-O2 -DMT2735 --sysroot=${CCTOOLBASE}/sysroot" CACHE STRING "C++ compiler flags")
set(CMAKE_EXE_LINKER_FLAGS "-O2 -DMT2735 --sysroot=${CCTOOLBASE}/sysroot" CACHE STRING "Executable linker flags")

# 设置系统名称和版本
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

# 指定查找包含文件和库文件的路径
set(CMAKE_FIND_ROOT_PATH ${CCTOOLBASE}/sysroot)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# 输出一些调试信息
message(STATUS "Using CCTOOLBASE: ${CCTOOLBASE}")
message(STATUS "Using LIB_RPATH: ${LIB_RPATH}")